package com.ymk.mapper;

import com.ymk.pojo.User;
import org.apache.ibatis.annotations.*;

public interface UserMapper {
    // 动态修改用户信息
    @Update("<script>" +
            "UPDATE user " +
            "<set>" +
            "   <if test='name != null'>name = #{name},</if>" +
            "   <if test='age != null'>age = #{age}</if>" +
            "</set>" +
            "WHERE id = #{id}" +
            "</script>")
    void updateUser(User user);

    // 批量删除（参数为ID数组）
    @Delete("<script>" +
            "DELETE FROM user WHERE id IN " +
            "<foreach collection='array' item='id' open='(' separator=',' close=')'>" +
            "   #{id}" +
            "</foreach>" +
            "</script>")
    void deleteBatch(int[] ids);
}